/*
 * (C) APUE
 * Illustrate using of signal handlers
 */

#include "apue.h"

static void sig_usr(int);	/* one handler for boht signals */

int main(void)
{
	if (signal(SIGUSR1, sig_usr) == SIG_ERR)
		err_quit("signal error: cannot cathc SIGUSR1");
	if (signal(SIGUSR2, sig_usr) == SIG_ERR)
		err_quit("signal error: cannot cathc SIGUSR2");
	while(1)
		pause();
}

static void sig_usr(int signo)	/* argument to signal number */
{
	if (signo == SIGUSR1)
		printf("received SIGUSR1\n");
	else if (signo == SIGUSR2)
		printf("received SIGUSR2\n");
	else
		printf("received signal %d\n", signo);
}
